package com.sangmo.fts.user.service;

import com.sangmo.boot.framework.cache.meta.Cache;
import com.sangmo.boot.framework.plugin.dataview.crud.service.DelegateViewService;
import com.sangmo.boot.framework.plugin.dataview.crud.service.ViewService;
import com.sangmo.fts.user.model.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.Set;

@Service
@Transactional
public class PermissionService extends DelegateViewService<Permission> {

    @Autowired
    private PermissionEntityService permissionEntityService;

    @Override
    protected ViewService<Permission> getEntityService() {
        return permissionEntityService;
    }

    @Cache(300)
    public Collection<String> findUriByApplicationAndRoles(String application, Set<String> roles) {
        return permissionEntityService.findByApplicationAndRoles(application, roles);
    }

    @Cache(300)
    public Collection<String> findUriByApplication(String application) {
        return permissionEntityService.findByApplication(application);
    }

}
